//测试
let express = require('express');
let path = require('path');
let mysql = require('mysql');
let jwt = require('jsonwebtoken');
//引入自定义模块
let seller = require('../model/seller');
let order = require('../model/order');
let user = require('../model/user')

var router = express.Router();
let name = 'chean';
let pw = '123';
//查看用户名是否存在
var format = function (a){
    if(a<10)
        return '0'+ a;
    else
        return a;
}

router.get('/',function(req,res,next){
    res.sendStatus(404);
    //_dirname:当前文件的路径，path.join():合并路径
});
router.post('/',function (req,res,next){
    //let userID = req.body.userID;

})
let userID = 1;
/*order.search(userID,function (result){
    if(result.length === 0){
        console.log('该用户不存在');
    }
    else {
        console.log(result);
    }
})*/
let ord = {
    userID: '1',
    orderID: '8',
    sellerID: '10',
    billSum: 1000,
    createTime: '0000-00-04 00:00:00',
    orderState: '5',
    cart: null,
    senderInfo: null
}
/*seller.all(1,function (res){
    console.log(res);
})*/

/*router.post('/',function(req,res) {
    let name = req.body.username;
    let pw = req.body.password;
    seller.search(name,function (len){
        if(len === 1){
            res.send('该商家存在');
        }
        else
            res.send('该商家不存在');
    })
})*/
/*router.post('/',function(req,res) {
    let name = req.body.username;
    let pw = req.body.password;
    let s = {
        sellerID: '2',
        name: '李四',
        address: '玄武区',
        phoneNum: 12345678912,
        licenseUrl: 'license',
        location: 'POINT(123,41)',
        businessHour: '9:00-19:00',
        range: '玄武区',
        class: '1'
    }
    seller.search(name,function (len){
        if(len === 1){
            res.send('该商家已存在');
        }
        else{
            seller.add(s);
        }
    })
})*/
/*var connection = mysql.createConnection({
    host     : '148.70.88.72',
    user     : 'test',
    password : '5280d5e6515378d4',
    database : 'test'
})
//启动连接
connection.connect(function (err){
    if(err)
        console.log(err);
});
connection.query('select * from `order` where orderID=?',[1], function (err, result) {
    if (err) throw err;
    console.log(result);
    connection.end();
})*/


module.exports = router;
